package com.alit.face.koala.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alit.face.koala.bean.http.KoalaRequestData;
import com.alit.face.koala.entity.KoalaCemara;
import com.alit.face.koala.entity.KoalaEmpLoyeeEntity;
import com.alit.face.koala.entity.UploadFileEntity;
import com.alit.face.koala.repository.KoalaEmployeeRepository;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class KoalaEmployeeSerivce {
  @Autowired
  private KoalaEmployeeRepository koalaEmployeeRepository;

  public KoalaEmpLoyeeEntity saveIfNotExists(String userId, String userInfo) {
    // 判断用户Id在本地是否存,如果不不存在,将用户信息添加到本地
    boolean existsById = koalaEmployeeRepository.existsById(userId);
    KoalaEmpLoyeeEntity entity = JSON.parseObject(userInfo, KoalaEmpLoyeeEntity.class);
    if (!existsById) {
      entity = koalaEmployeeRepository.save(entity);
    } else {
      log.info("本地用户存在,无需添加:" + userId);
    }
    return entity;
  }

  public void second(KoalaRequestData koalaRequestData, KoalaCemara koalaCemara, UploadFileEntity uploadFileEntity,
      double faceSimilarity, String koalaStrangerSayString) {
    // TODO Auto-generated method stub
    
  }
}
